﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class allreply : System.Web.UI.Page
{
    protected BLL.Message bllmessage = new BLL.Message();
    protected StringBuilder sb = new StringBuilder();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (common.isLoginOrNot())
        {
            int uid = ((MODEL.Users)Session["currentUser"]).UId;
            if (bllmessage.getAllMessage2(uid) != null || bllmessage.getReply2(uid) != null)
            {
                if (bllmessage.getAllMessage2(uid) != null)
                {
                    //绑定留言
                    List<MODEL.Message> models = bllmessage.getAllMessage2(uid);
                    foreach (MODEL.Message m in models)
                    {
                        //跳到该页面的时候留言标志为看过
                        bllmessage.isLookByMid(m.MId);
                    }
                    rpMessage.DataSource = models;
                    rpMessage.DataBind();
                }
                if (bllmessage.getReply2(uid) != null)
                {
                    //绑定回复
                    List<MODEL.Message> models2 = bllmessage.getReply2(uid);
                    foreach (MODEL.Message m in models2)
                    {
                        //跳到该页面的时候回复标志为看过
                        bllmessage.isLookByMid(m.MId);
                    }
                    rpReply.DataSource = models2;
                    rpReply.DataBind();
                }
            }
            else
            {
                sb.Append("您当前没有留言");
            }
            
        }
        else
        {
            Response.Redirect("index.aspx");
        }
    }
}